package models

import "tuowei.com/common/models"

type SysTeachingPointSimple struct {
	Id   int    `gorm:"type:int(10);primaryKey;autoIncrement;comment:编码"  json:"id"`
	Name string `gorm:"type:varchar(64);comment:名字" json:"name"`
}

func (tp SysTeachingPointSimple) TableName() string {
	return "sys_teaching_point"
}

// 教学点表
type SysTeachingPoint struct {
	Id           int    `gorm:"type:int(10);primaryKey;autoIncrement;comment:编码"  json:"id"`
	Name         string `gorm:"type:varchar(64);comment:名字" json:"name"`
	ProvinceId   int    `gorm:"type:int(10);column:province_id;comment:省id" json:"province_id"`
	CityId       int    `gorm:"type:int(10);column:city_id;comment:市id" json:"city_id"`
	CountyId     int    `gorm:"type:int(10);column:county_id;comment:县id" json:"county_id"`
	DepartmentId int    `gorm:"type:int(10);column:department_id;comment:所属部门id" json:"department_id"`
	// 关联的负责人
	Controllers *[]SysUser `gorm:"many2many:sys_teaching_point_enrollment;foreignKey:id;joinForeignKey:point_id;References:user_id;joinReferences:enrollment_id"`
	// 关联的招生老师
	Enrollments *[]SysUser `gorm:"many2many:sys_teaching_point_teacher;foreignKey:id;joinForeignKey:point_id;References:user_id;joinReferences:enrollment_id"`
	Province    *SysRegion `gorm:"foreignKey:province_id"`
	City        *SysRegion `gorm:"foreignKey:city_id"`
	County      *SysRegion `gorm:"foreignKey:county_id"`
	Department  *SysDept   `gorm:"foreignKey:department_id"`
	Address     string     `gorm:"type:varchar(64);column:address;comment:地址" json:"address"`
	models.ModelTime
}

func (tp SysTeachingPoint) TableName() string {
	return "sys_teaching_point"
}

type SysTeachingPoint2Enrollment struct {
	Id           int `gorm:"type:int(10);primaryKey;autoIncrement;comment:编码"  json:"id"`
	PointId      int `gorm:"index;type:int(10);comment:教学点id" json:"point_id"`
	EnrollmentId int `gorm:"index;type:int(10);comment:负责人id" json:"enrollment_id"`
}

func (te SysTeachingPoint2Enrollment) TableName() string {
	return "sys_teaching_point_enrollment"
}

//sys_teaching_point_teacher

type SysTeachingPoint2teacher struct {
	Id           int        `gorm:"type:int(10);primaryKey;autoIncrement;comment:编码"  json:"id"`
	PointId      int        `gorm:"index;type:int(10);comment:教学点id" json:"point_id"`
	EnrollmentId int        `gorm:"index;type:int(10);comment:招生老师id" json:"enrollment_id"`
	Classes      []SysClass `gorm:"foreignKey:dept_id;references:id"`
}

func (te SysTeachingPoint2teacher) TableName() string {
	return "sys_teaching_point_teacher"
}
